from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
driver.get('file:///D:/nsd2404/html/register.html')
# 输入用户名
driver.find_element(By.CSS_SELECTOR, '#user').send_keys('admin')
sleep(3)
# 1.刷新浏览器
driver.refresh()
# 点击链接进入
driver.find_element(By.PARTIAL_LINK_TEXT, '新浪').click()
sleep(3)
# 2.关闭主窗口：第一次打开的窗口
# driver.close()
# 4.获取当前网页的标题
title = driver.title
# 5.获取当前网页的url
url = driver.current_url
print('网页标题：', title)
print('网址：', url)
sleep(3)
# 3.关闭浏览器，所有窗口
driver.quit()